ROSAENG-60112 | test: add tests for OIDC commands#3316
Conversation
|
Skipping CI for Draft Pull Request. |
📝 WalkthroughWalkthroughThis pull request adds Ginkgo/Gomega test coverage for OIDC config creation, OIDC provider creation, and OIDC config deletion strategy selection. It also adds suite entrypoints for the new test packages. Separately, it updates pinned Tekton bundle digests for 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/test all |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/create/oidcprovider/cmd_test.go (1)
25-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor duplication in mock response setup.
The OidcConfig/OidcThumbprint responder setup (Lines 30-40) is duplicated verbatim in the failure spec (Lines 72-82). Could be extracted into a small helper to reduce repetition.
Also applies to: 67-94
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/create/oidcprovider/cmd_test.go` around lines 25 - 51, The OidcConfig and OidcThumbprint responder setup in the CreateOIDCProvider test is duplicated across the success and failure specs, so extract that repeated mock setup into a small helper and reuse it from the CreateOIDCProvider test cases. Keep the helper close to the existing test code and have it encapsulate the shared t.ApiServer.AppendHandlers calls while preserving the existing oidcConfigId and issuerUrl inputs used by CreateOIDCProvider.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/create/oidcprovider/cmd_test.go`:
- Around line 25-51: The OidcConfig and OidcThumbprint responder setup in the
CreateOIDCProvider test is duplicated across the success and failure specs, so
extract that repeated mock setup into a small helper and reuse it from the
CreateOIDCProvider test cases. Keep the helper close to the existing test code
and have it encapsulate the shared t.ApiServer.AppendHandlers calls while
preserving the existing oidcConfigId and issuerUrl inputs used by
CreateOIDCProvider.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 0e4f8200-6bca-4860-b279-b612113584af
📒 Files selected for processing (8)
cmd/create/oidcconfig/cmd_test.gocmd/create/oidcconfig/oidcconfig_suite_test.gocmd/create/oidcprovider/cmd_test.gocmd/create/oidcprovider/oidcprovider_suite_test.gocmd/dlt/oidcconfig/cmd_test.gocmd/dlt/oidcconfig/oidcconfig_suite_test.gocmd/dlt/oidcprovider/cmd_test.gocmd/dlt/oidcprovider/oidcprovider_suite_test.go
0862aee to
dcc52c6
Compare
|
/override ci/prow/security |
|
@olucasfreitas: Overrode contexts on behalf of olucasfreitas: ci/prow/security DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@amandahla @jerichokeyne ready for review when you can |
|
/approve |
Add focused tests for 3 OIDC-related commands, all previously at 0% coverage. Tests target functions that return errors or are pure, without needing to refactor the legacy os.Exit pattern. - cmd/create/oidcconfig: getOidcConfigStrategy factory (5 cases) and ManagedAutoStrategy.executeNoExit (2 cases via OCM mock) - cmd/create/oidcprovider: CreateOIDCProvider exported function (4 cases with OCM + AWS mocks, including FetchOidcThumbprint failure) - cmd/dlt/oidcconfig: getOidcConfigStrategy factory (4 cases) Skip cmd/dlt/oidcprovider (buildCommand is a commandbuilder pass-through already covered by pkg/aws/commandbuilder tests) and cmd/register/oidcconfig (no extracted helpers that return errors).
dcc52c6 to
ffbb313
Compare
|
/approve |
|
/override ci/prow/security |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amandahla, olucasfreitas The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amandahla, olucasfreitas The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@olucasfreitas: Overrode contexts on behalf of olucasfreitas: ci/prow/security DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/create/oidcconfig/cmd_test.go (1)
67-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider asserting the
IssuerUrlside effect too.
executeNoExitalso setss.oidcConfigInput.IssuerUrlfrom the created config before returning the ID (percmd.go'sexecuteNoExit). Asserting this would tighten coverage of the success path.Suggested addition
id, err := strategy.executeNoExit(t.RosaRuntime) Expect(err).NotTo(HaveOccurred()) Expect(id).To(Equal("managed-oidc-123")) + Expect(input.IssuerUrl).To(Equal("https://oidc.managed.example.com"))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/create/oidcconfig/cmd_test.go` around lines 67 - 81, The success test for CreateManagedOidcConfigAutoStrategy only checks the returned ID, but executeNoExit also mutates oidcConfigInput.IssuerUrl from the created OIDC config. Update the test around executeNoExit to assert that the input’s IssuerUrl is set to the expected issuer URL alongside the existing ID assertion, using the CreateManagedOidcConfigAutoStrategy and OidcConfigInput symbols to locate the flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/create/oidcconfig/cmd_test.go`:
- Around line 67-81: The success test for CreateManagedOidcConfigAutoStrategy
only checks the returned ID, but executeNoExit also mutates
oidcConfigInput.IssuerUrl from the created OIDC config. Update the test around
executeNoExit to assert that the input’s IssuerUrl is set to the expected issuer
URL alongside the existing ID assertion, using the
CreateManagedOidcConfigAutoStrategy and OidcConfigInput symbols to locate the
flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 6e3b42bb-2a53-4044-b0c8-2aa3ebe094de
📒 Files selected for processing (10)
.tekton/rosa-cli-e2e-test-pull-request.yaml.tekton/rosa-cli-e2e-test-push.yaml.tekton/rosa-pull-request.yaml.tekton/rosa-push.yamlcmd/create/oidcconfig/cmd_test.gocmd/create/oidcconfig/oidcconfig_suite_test.gocmd/create/oidcprovider/cmd_test.gocmd/create/oidcprovider/oidcprovider_suite_test.gocmd/dlt/oidcconfig/cmd_test.gocmd/dlt/oidcconfig/oidcconfig_suite_test.go
✅ Files skipped from review due to trivial changes (3)
- .tekton/rosa-pull-request.yaml
- cmd/create/oidcprovider/oidcprovider_suite_test.go
- .tekton/rosa-push.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
- cmd/dlt/oidcconfig/oidcconfig_suite_test.go
- cmd/create/oidcconfig/oidcconfig_suite_test.go
- cmd/dlt/oidcconfig/cmd_test.go
- cmd/create/oidcprovider/cmd_test.go
|
/override ci/prow/security |
|
@olucasfreitas: Overrode contexts on behalf of olucasfreitas: ci/prow/security DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@olucasfreitas: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3316 +/- ##
==========================================
+ Coverage 28.03% 28.33% +0.29%
==========================================
Files 334 334
Lines 36710 36710
==========================================
+ Hits 10293 10401 +108
+ Misses 25663 25552 -111
- Partials 754 757 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Summary
Add focused tests for 4 OIDC-related commands, all previously at 0% coverage. Tests target functions that return errors or are pure, without needing to refactor the legacy os.Exit pattern.
Detailed Description of the Issue
The OIDC commands are required for the STS cluster creation flow and had no automated test coverage. This PR adds tests for the testable internals: strategy factory functions, exported helpers that return errors, and pure command builders.
Related Issues and PRs
Type of Change
Previous Behavior
No automated test coverage for
cmd/create/oidcconfig,cmd/create/oidcprovider,cmd/dlt/oidcconfig, orcmd/dlt/oidcprovider.Behavior After This Change
15 new test cases across 4 commands:
cmd/create/oidcconfiggetOidcConfigStrategyfactory (5 cases),ManagedAutoStrategy.executeNoExit(2 cases)cmd/create/oidcproviderCreateOIDCProviderexported function with OCM + AWS mockscmd/dlt/oidcconfiggetOidcConfigStrategyfactory (4 cases)cmd/dlt/oidcproviderbuildCommandpure functionIntentionally skipped:
cmd/register/oidcconfig(no extracted helpers that return errors).How to Test (Step-by-Step)
Test Steps
go test ./cmd/create/oidcconfig/... ./cmd/create/oidcprovider/... ./cmd/dlt/oidcconfig/... ./cmd/dlt/oidcprovider/... -count=1go vet ./cmd/create/oidcconfig/... ./cmd/create/oidcprovider/... ./cmd/dlt/oidcconfig/... ./cmd/dlt/oidcprovider/...Expected Results
go vetcleanBreaking Changes
Developer Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make install-hookshas been run in this clone.make testpasses.make lintpasses.Summary by CodeRabbit
Tests
go test.Chores